package com.zhongying.jf.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author liyuxuan
 * @Description
 * @Email liyuxuan@zhongyingjinrong.com
 * Created on 2017/4/24 下午3:52
 * Copyright (c) 2017 All Rights Reserved.
 */
public class Number {


    public static String extractNumber(String str){
        char[] b = str.toCharArray();
        String result = "";
        for (int i = 0; i < b.length; i++){
            if (("0123456789.").indexOf(b[i] + "") != -1){
                result += b[i];
            }
        }
        return result;
    }

    /**
     * 获取字符串中的纯数字
     * @param str
     * @return
     */
    public static String getNum(String str) {
        String regEx = "[^0-9]";
        Pattern p = Pattern.compile(regEx);
        Matcher order = p.matcher(str);
        String ordId = order.replaceAll("").trim();
        return ordId;
    }

}
